Going
to the (VB Editor’s) Dark Side
So, if you really,
really want to go to the dark side with the VBE, try this . . .
Fire up Excel if she’s not already running. And then meander over to the Visual
Basic Editor.
You can click the
Visual Basic button on the Developer Ribbon Tab.
Although, if you’re a
keyboard shortcut freak like me, it’s way faster to press ALT+F11 on your
keyboard.
If you’ve got a code
module open already, your screen might look something like this:
Brrr. Cold White. Let’s change that.
So now you’re in the
VBE, from the Tools menu choose Options.
This will display the
Options screen. Now select the Editor Format tab:
This screen gives you
all the options to change the colours.
Let’s take a look at
the choices you have in a bit more detail.
The Code
Color list has each type of VBA code display you can change.
For example, ‘Normal Text’ is standard VBA text while ‘Keyword Text’ is for VBA
keywords like ‘Dim’ and ‘Function’.
Foreground represents the colour of the
text itself.
Background represents the colour of the
page directly behind the text
Indicator is the colour of any symbol in
the margin such as the circle which appears in the margin when you set a break
point.
Font is exactly what it says on the tin. It allows you to
change the font, although the selection is limited.
How to Customize the Visual Basic Editor Colors
Let’s change the colours so it look like the proper
VBA code in Excel’s Visual Basic Editor screenshot above.
1
If
it’s not currently open, display the Options screens. In the
VBA Editor, from the Tools menu, select Options and
then select the Editor Format tab.
2
In
the list of Code Colors, select ‘Normal Text’.
3
From
the Foreground dropdown list, select ‘Yellow’.
4
From
the Background dropdown list select ‘Black’.
5
From
the Indicator dropdown, select ‘Auto’.
You now want to repeat
this process for each of the colour choices below:
Call me old school,
but I like the FixedSys font.
It’s thick and easy to read. Have a play with some of the font
options.
When you’re done, click OK.
Depending on which
windows you have showing, your screen will look something like this example
which also shows a Break Point and a code syntax error:
The first thing you’ll
notice is that Excel does not apply your fancy colour
scheme to the entire Visual Basic Editor.
In fact, Excel only
changes the main code window and the Immediate Window.
Hmm,
not what I was hoping for. How about you?
However if you hiding
all the other windows and just leave the main code window visible with the menu
and toolbars showing, you can end up with something like this:
Admittedly I’m not one
to claim any form of “colour co-ordination skills” so
you’ll probably want to experiment with some colour
combinations or copy the colours from your favourite ‘modern’ code editor. Note however, that the
selection of colours is fixed and you can’t edit
them.
If after all your experimenting with colours
you decide you’d prefer the original colour, you can
always set them back to the default.
Unfortunately, you’ll
have to do that manually as well. It’s a shame there’s no option so save a colour combination as a ‘theme’.
If you do decide you’d
prefer to code VBA on the ‘Light Side’, here’s the colour
scheme so you can change it back:
The whole process is a
little tedious, I know, and you’ll probably need to experiment a little to get
the “look” you’re after.
Third Party Tools to Customize the VBE Editor Colors
If you want more
control over the Visual Basic Editor Colour than what
Microsoft grant you, you also have some third-party tools available.
FMS Total Visual CodeTools
FMS, who have been making excellent VBA-related development
tools for decades have a product called Total Visual CodeTools.
This includes a ‘VBE Color Scheme Manager’ so you can “easily see and set
colors for your editor”.
It may not have the
ability to edit the colours, but it allows you to
save colour schemes and see the affect
of the changes as you make them.
VBE Theme Editor
Meanwhile a SuperUser
contributor Dimitri Mitropoulos (a.k.a. Gallaux) created a GitHub project called VBE Custom Colors. Dimitri even made the source code available if you want to have a play with it.The really cool thing
about the VBE Theme Editor is that it allows you to change the default colors
so you can get results like this.
Be wary though, as the approach does make changes to the Visual
Basic Editor Dynamic Linked Library file (VBE.DLL). Always, I mean always,
make a backup before you change any system files.
Conclusion
As you can see,
changing the colours of the Visual Basic Editor is
possible albeit limited.
Have you found any
smarter ways to customize the look and feel of the Visual Basic Editor?
Let me know in the
comments below.
Alternatively, would
you care to share a screenshot of your Visual Basic Editor customizations?